# Maintainer: Frederik Schwan <freswa at archlinux dot org>

pkgname=ctop
pkgver=0.7.7
pkgrel=2
pkgdesc='Top-like interface for container metrics'
arch=('loong64' 'x86_64')
url='https://ctop.sh/'
license=('MIT')
depends=('glibc')
makedepends=('go')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/bcicen/ctop/archive/refs/tags/v${pkgver}.tar.gz")
b2sums=('21bcc7a7996cf8cd1bfb87da30bbccd3f1c9a257b1140a81795186c466c7e499233e691eca3dac2e953fb9e46d0cacd78ee87abcbfd01965401d3666f3ff8eff')


build() {
  cd ${pkgname}-${pkgver}
  export CGO_LDFLAGS="${LDFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
  go build .
}

package() {
  install -Dm755 ${pkgname}-${pkgver}/${pkgname} "${pkgdir}"/usr/bin/${pkgname}
  install -Dm644 ${pkgname}-${pkgver}/LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

